package io;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class ReadStringDemo2 {
    public static void main(String[] args) throws IOException {
        //低级流:文件流，负责从文件中读取字节数据
        //FileInputStream fis=new FileInputStream("./fos.txt");
        FileInputStream fis=new FileInputStream("./src/io/ReadStringDemo2.java");
        //高级流:字符流，将字节按照指定的字符集还原为字符
        InputStreamReader isr=new InputStreamReader(fis, StandardCharsets.UTF_8);
        //高级流:BufferedReader:可以按行读取字符串
        BufferedReader br=new BufferedReader(isr);
        /*
        String line=br.readLine();//按行读取字符串    一行
        System.out.println(line);
        String line=br.readLine();
        System.out.println(line);
         */
        String line;
        while((line=br.readLine())!=null){
            System.out.println(line);
        }
        /*
        while(true){
            String line=br.readLine();
            System.out.println(line);
            if (line==null){
                break;
            }
        }
         */
        br.close();
    }
}
